<template>
	<view>
		<phone-search-list :phones="phones" @paramClick="paramClick"></phone-search-list>
		<s-popup custom-class="demo-popup" position="bottom" v-model="visible">
		  	<view class="tel" @click="searchHouse">他的房源</view>		
			<view class="tel" @click="tel">联系他</view>	  		  
		</s-popup>
	</view>		
</template>

<script>
	
	import phoneSearchList from '@/components/phones-address/phone-search-list.vue'
	import sPopup from '@/components/s-popup/index.vue'
	export default {
		name:"phone-search",
		components:{
			phoneSearchList,
			sPopup
		},
		data() {
			return {
				phones:{},
				visible: false,
				person_id:0,
			}
		},
		onLoad (option) {
			this.phones = JSON.parse(unescape(option.phones))
		},
		methods:{
			paramClick (e) {
				this.visible = true
				this.person_id = e.id
			},
			searchHouse(){
				uni.request({
					url: this.websiteUrl+'/api.php/Friends/detail',
					method: 'POST',
					header: {
						'content-type':'application/x-www-form-urlencoded',						
					},
					data: {id:this.person_id},
					success: res => {
						if(res.data.code == 1){
							var agent_id = res.data.data.agent_id
							uni.navigateTo({															
								url:"/pages/index/her?user_id="+agent_id
							})
						}
					},
					
				});
				
			},
			tel(){
				uni.request({
					url: this.websiteUrl+'/api.php/Friends/detail',
					method: 'POST',
					header: {
						'content-type':'application/x-www-form-urlencoded',						
					},
					data: {id:this.person_id},
					success: res => {
						if(res.data.code == 1){
							var mobile = res.data.data.mobile
							uni.makePhoneCall({
								phoneNumber:mobile
							})
						}
					},
					
				});
			}
			
			
			
		}
	}
</script>

<style>
	.tel{
		width:100%;
		height:112rpx;
		line-height:112rpx;
		text-align:center;
		font-size:30rpx;
		border-top:#E5E5E5 1rpx solid;
	}
</style>
